package com.taiji.web.controller.workOrder;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.taiji.common.annotation.Log;
import com.taiji.common.core.controller.BaseController;
import com.taiji.common.core.domain.AjaxResult;
import com.taiji.common.enums.BusinessType;
import com.taiji.workOrder.domain.OrderLogs;
import com.taiji.workOrder.service.IOrderLogsService;
import com.taiji.common.utils.poi.ExcelUtil;
import com.taiji.common.core.page.TableDataInfo;

/**
 * 工单日志Controller
 * 
 * @author taiji
 * @date 2023-03-09
 */
@RestController
@RequestMapping("/workOrder/orderLogs")
public class OrderLogsController extends BaseController
{
    @Autowired
    private IOrderLogsService orderLogsService;

    /**
     * 查询工单日志列表
     */
    @PreAuthorize("@ss.hasPermi('workOrder:orderLogs:list')")
    @GetMapping("/list")
    public TableDataInfo list(OrderLogs orderLogs)
    {
        startPage();
        List<OrderLogs> list = orderLogsService.selectOrderLogsList(orderLogs);
        return getDataTable(list);
    }

    /**
     * 导出工单日志列表
     */
    @PreAuthorize("@ss.hasPermi('workOrder:orderLogs:export')")
    @Log(title = "工单日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderLogs orderLogs)
    {
        List<OrderLogs> list = orderLogsService.selectOrderLogsList(orderLogs);
        ExcelUtil<OrderLogs> util = new ExcelUtil<OrderLogs>(OrderLogs.class);
        util.exportExcel(response, list, "工单日志数据");
    }

    /**
     * 获取工单日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('workOrder:orderLogs:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(orderLogsService.selectOrderLogsById(id));
    }

    /**
     * 新增工单日志
     */
    @PreAuthorize("@ss.hasPermi('workOrder:orderLogs:add')")
    @Log(title = "工单日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderLogs orderLogs)
    {
        return toAjax(orderLogsService.insertOrderLogs(orderLogs));
    }

    /**
     * 修改工单日志
     */
    @PreAuthorize("@ss.hasPermi('workOrder:orderLogs:edit')")
    @Log(title = "工单日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderLogs orderLogs)
    {
        return toAjax(orderLogsService.updateOrderLogs(orderLogs));
    }

    /**
     * 删除工单日志
     */
    @PreAuthorize("@ss.hasPermi('workOrder:orderLogs:remove')")
    @Log(title = "工单日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(orderLogsService.deleteOrderLogsByIds(ids));
    }
}
